home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.021.Dynamo / v3.1 changes < prev   
Encoding:
Text File  |  1990-06-24  |  9.8 KB  |  230 lines  |  [TEXT/MPS ]

  1. Dynamo 3.1 changes:
  2.  
  3. I have been busy changing things for no reason at all, and here's where I stand:
  4. (This is a joke.  I had reasons.  I just can't remember what they were.)
  5. ((This is a joke.))
  6.  
  7.  
  8. 1)    BUILDAPP.SYSTEM has changed.  The new build script sample looks like this:
  9.  
  10. DUMMY                            ;The default script filename.
  11. 0,$0800,SAMPLE.BIN                ;Sample app, segment 1 (on server).
  12. 0,$8000,SAMPLE.BIN.2            ;Sample app, segment 2 (on server).
  13. 0,$9000,SAMPLE.BIN.3            ;Sample app, segment 3 (on server).
  14. $80,$800                        ;Starting address.
  15. $                                ;Display starting address in hex.
  16. $                                ;Display application size in hex.
  17. N                                ;Skip save file prompt (and don't save it).
  18. $FF,0,SAMPLE.SYSTEM                ;Target filename, filetype, and auxtype.
  19.  
  20. The difference is the 8th line.  This is new.  You don't have to be prompted from
  21. the keyboard anymore.  You can put a Y,N, or Q here instead of typing it.  If you
  22. don't put one of these letters (lowercase is okay, too), then you will be prompted
  23. from the keyboard.  As a convention, I recommend a ? if you want to be prompted.
  24.  
  25.  
  26. 2)    The runtime and macros have been revised a few times lately.  One of these
  27.     changes was to optimize _decout, _add, _sub, _mul, _div, _set, _index,
  28.     _getb, _getw, _putb, and _putw.  This was a bad idea, since it makes it
  29.     even more difficult to do Dynamo versions for other assemblers and keep
  30.     them as compatible as possible.  This feature in the MPW version caused
  31.     a greater leel of incompatibility, so I have removed it.  There is a
  32.     benefit that remained.  There were some entry points added for the array
  33.     indexing and accessing routines for the optimizations.  These entry points
  34.     are still there.  Given that _index, _getb, _getw, _putb, and _putw are no
  35.     longer figuring out which entry point to call, there have been some macros
  36.     added.  These are (logically enough) _indexl, _getbl, _getwl, _putbl, and
  37.     _putwl.  These don't load a 2-byte constant into the accumulator and
  38.     y-register.  Rather, they load a one byte value into the accumulator and
  39.     then call the alternate entry point (which loads the accumulator with 0
  40.     and branches to the regular entry point).  If you have a constant in the
  41.     range 0-255, as an optional syntax, you can still call _getb, _getw, _putb,
  42.     and _putw, as long as you put a < in the constant parameter to indicate it
  43.     is a 1-byte value.  For _index, this is the ONLY way to just load the
  44.     accumulator and call the alternate entry point.  There is no _indexl
  45.     macro.  The reason for this is that you can have multiple indexes for
  46.     one instance of _index, so each parameter needs to demonstrate if it is
  47.     a 1-byte or 2-byte value.  Some syntax examples would be:
  48.         _index        #345,,<#3
  49.         _getw        var1,<#3
  50.  
  51.     A constant parameter can now take these following forms and it produces
  52.     the following code:
  53.         1)    = #constant
  54.                 lda #<constant
  55.                 ldy #>constant
  56.         2)    = *address
  57.                 lda address
  58.                 ldy address+1
  59.         3)    = #<constant
  60.                 lda #<constant
  61.         4)    = *<address
  62.                 lda address
  63.  
  64.     As a sample we want to calculate the number of bytes necessary to store a
  65.     rectangle of data on the screen.  We have a rectangle stored at $4000, in
  66.     the form x1,y1,x2,y2.  The x-values take two bytes (0-280), and the y-values
  67.     take 1 byte (0-192).  How many bytes do this take?
  68.         First, we calculate which row we are starting in.
  69.  
  70.         The formula is:  bytes = (int((x2 + 6) / 7) - int(x1 / 7) * (y2 - y1)
  71.         The macros to do this formula would look like:
  72.  
  73.             rect    equ        $4000
  74.             x1        equ        0
  75.             y1        equ        2
  76.             x2        equ        3
  77.             y2        equ        5
  78.  
  79.     1)                _set    temp,*rect+x1        ;temp = x1
  80.     2)                _div    ,#<7                ;temp = int(x1 / 7)
  81.     3)                _set    bytes,*rect+x2        ;bytes = x2
  82.     4)                _add    ,#<6                ;temp = x2 + 6
  83.     5)                _div    ,#<7                ;bytes = int((x2 + 6) / 7)
  84.     6)                _subvar    ,temp                ;bytes = bytes - temp
  85.                                                 ;We now have # of bytes wide (in bytes).
  86.     7)                _set    temp,*<rect+y2        ;temp = y2
  87.     8)                _sub    ,*<rect+y1            ;temp = y2 - y1
  88.     9)                _mul    bytes,temp            ;bytes = bytes * temp
  89.  
  90.         The code for these macros would look like:
  91.     1)                ldx        #temp
  92.                     lda        rect+x1
  93.                     ldy        rect+x1+1
  94.                     jsr        setcon                ;Set temp to a 2-byte value.
  95.  
  96.     2)                lda        #<7
  97.                     jsr        divconl                ;Divide temp by a 1-byte constant.
  98.  
  99.     3)                ldx        #bytes
  100.                     lda        rect+x2
  101.                     ldy        rect+x2+1
  102.                     jsr        setcon                ;Set bytes to a 2-byte value.
  103.  
  104.     4)                lda        #<6
  105.                     jsr        addconl                ;Add a 1-byte constant to bytes.
  106.  
  107.     5)                lda        #<7
  108.                     jsr        divconl                ;Divide bytes by a 1-byte constant.
  109.  
  110.     6)                ldy        #temp
  111.                     jsr        subvar                ;Subtract temp from bytes.
  112.  
  113.     7)                ldx        #temp
  114.                     lda        rect+y2
  115.                     jsr        setconl                ;Set temp to a 1-byte value.
  116.  
  117.     8)                lda        rect+y1
  118.                     jsr        subconl                ;Subtract a 1-byte value from temp.
  119.  
  120.     9)                ldx        #bytes
  121.                     ldy        #temp
  122.                     jsr        mulvar                ;bytes = bytes * temp
  123.  
  124.         Since the y-values are only 1 byte, it is less code to write steps 7-9 like this:
  125.                     lda        rect+y2
  126.                     sec
  127.                     sbc        rect+y1
  128.                     _mull
  129.         Note that bytes didn't have to be redeclared for the multiply.  It is still
  130.         around from step 3.  (Steps 4 thru 6 start with a comma, thus leaving the
  131.         x-register alone.)  Also note that we said _mull, NOT _mul.  Since we are
  132.         not stating what we are multiplying by, we aren't telling the macros how
  133.         big the value is.  Since it doesn't know, it has to assume we know what we
  134.         are doing.  If we said _mul, it would assume that we wanted to multiply by
  135.         a 2-byte value, and the y-register would hold the hi-byte.  That isn't what
  136.         we want in this case.  We want to multiply by a 1-byte value, so we have to
  137.         use the _mull macro instead.  This needs to be watched carefully!! 
  138.  
  139.         So, we used the macros when it helped (readability and/or code size) and wrote
  140.         regular assembly code when it was easy and smaller.  The best of both worlds!!
  141.  
  142.  
  143. 3)    Another runtime change that stayed in is a value called strvalcount.  This
  144.     value is calculated by _strval and _midstrval.  strvalcount is the number
  145.     of characters involved in the evaluation of the string value.  Some examples:
  146.  
  147.         _strval of:  -$100FG                            returns -4111 (or 61425) 
  148.                                                         and sets strvalcount to 6.
  149.  
  150.         _midstrval(from char 4) of:  ------345.6789        returns 345 (two minuses
  151.                                                         cancel each other out) and
  152.                                                         sets strvalcount to 5.
  153.  
  154.     This addition is very useful when parsing a string.  If you pull an integer
  155.     value from a string, you may want to know how many characters the runtime
  156.     routine used.  If this value wasn't set, you would have to know all of the
  157.     rules that the runtime used to evaluate the integer and walk through the
  158.     string again yourself.  This is wasteful, and also can be a problem if the
  159.     evaluation method is ever changed.  If that occured, you would have to change
  160.     code in more than one place.  strvalcount is not returned in any register.
  161.     The registers are all used already.  Also, you commonly don't care about this
  162.     value.  (When you do care, you need it badly.)  strvalcount is simply a byte
  163.     value that you have external access to.  If you want it, just load it.
  164.  
  165.  
  166. 4)    Another _strval or _midstrval calculated value is strvaldigit.  This tells
  167.     you if the string evaluation routine actually found any digits.  When you
  168.     are returned a value of 0, you don't know if this was because there was a
  169.     value of 0 (or -$0000 for that matter), or because the routine ran into a
  170.     non-integer character before it could find any characters to evaluate.  The
  171.     strvaldigit value tells you which occured.  It holds the number of digit
  172.     characters encountered.  (If strvaldigit is 0, then the integer result must
  173.     also be 0.)  Note that strvalcount can be greater than 0 even if strvaldigit
  174.     is 0.  This would occur in the string: -$G  In this case strvalcount would be
  175.     2 (the - and the $) and strvaldigit would be 0 (there were no legal digits).
  176.  
  177.  
  178. 5)    Another change (kind of big, kind of small) is how the variable space is
  179.     defined.  It used to be that varstart was equated in app.config.  If it
  180.     changed, the runtime has to be reassembled and turned into a library again.
  181.     This has been leading to errors that are time consuming to trace.  Instead,
  182.     what is being done is to let the linker worry about it.  There now needs to
  183.     be a varspace space (256 bytes) for the linker to link in.  Once this is
  184.     done, varspace can be kept, or you can use LinkIIGS and MakeBigIIGS to throw
  185.     it away.  The runtime doesn't demand that varspace be part of your program.
  186.     All it cares about is that there are 256 bytes somewhere in memory that it
  187.     will access.  So, it isn't necessary that the application carry these 256
  188.     bytes around.  (Save disk space -- just say no!!)  It is necessary to have
  189.     something for the linker to work with, however.  So, the sample application
  190.     now has an additional segment called varspace.  It is thrown away in this
  191.     example.  This is done by linking it into a separate segment that we don't
  192.     care about.  Check out the make file for exactly how this is done.
  193.     It is worth noting that if you wish to move where the 256-byte varspace
  194.     area is, all you need to do is change the makefile.  Just change the -org
  195.     value for the segment "trash".
  196.  
  197. 6)    More support for indirection and dereferencing has been added.  There are now
  198.     an additional macro for dereferencing, as well as syntax extensions to handle
  199.     multi-level-dereferencing in conjunction with other macros.  Here is some code
  200.     from sample.a that demonstrates the extent of the indirection capabilities:
  201.  
  202.         _set    var1,**@ptr1        ;Set var1 to double-dereferenced @ptr1.
  203.                                     ;var1 has address @ptr3 now.
  204.         _add    ,#<2                ;Add 2 to the pointer.
  205.         _vderef                        ;Dereference var1 again (into itself).
  206.                                     ;var1 has address @ptr4 now.
  207.         _vderef                        ;Dereference var1 again (into itself).
  208.                                     ;var1 has address @ptr5 now.
  209.         _vderef                        ;Dereference var1 again (into itself).
  210.                                     ;var1 has value from @ptr5 now.
  211.         _vhexout                    ;Output the variable value (which is $1234)
  212.         jmp        @past
  213.  
  214. @ptr1        dc.w    @ptr2
  215. @ptr2        dc.w    @ptr3
  216. @ptr3        dc.w    0,@ptr4
  217. @ptr4        dc.w    @ptr5
  218. @ptr5        dc.w    $1234
  219.  
  220. @past        equ        *
  221.  
  222.  
  223.  
  224.  
  225. Well, this ought to be enough arbitrary changes for version 3.1 -- have fun.
  226.  
  227.  
  228.  
  229. Eric Soldan, Apple II DTS
  230.